<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>申请书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript"
	src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript"
	src="${res}/js/keyword/keywordtips.js"></script>	
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>

<style>
	textarea{overflow:auto;}
</style>

<script type="text/javascript">
$(function(){
	queryflex();
});
/**
 * 申请书提交方法
 */


var ctxpath = "${ctx}";
var prcWin = new progressWin("${res}");//初始化遮罩层
/**
 * 页面初始化方法 所有的都定义在里面
 */
$(document).ready (function() {
	$("#wbox1").click(function() {
		check("check");
	});
	
	$("#wbox2").click(function() {
		
		check("check");
		
	});
/* 	$("table.t_css").not("[id='finances']").not("[id='checkbox_table_']").not("[id='budgetsMsg2']").not("[id='basicInfo']").each(function(){
		$(this).find("tr:even").addClass("li_1");
		$(this).find("tr:odd").addClass("li_2");
	}); */
	$("table").addClass("table01");
	$("#checkbox_table_").removeClass("table01");
	$("#feaReport_upload").removeClass("table01");
    $('div').find("[id^='checkbox_dyn_']").find("tr").removeClass("li_1").removeClass("li_2");
    $('div').find("[id^='checkbox_dyn_']").find("td").css("border",'0px solid');
	
	window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
});

$(document).ready(function() {
	fileInit("feaReport_upload","PDF");
/* 	fileInit("prpContent_upload","JPG,PDF,TIFF,XLS,DOC,WPS",null,"{'JPG':'51200','PDF':'51200','TIFF':'51200','XLS':'51200','DOC':'51200','WPS':'51200'}");	
 */ 
	fileInit("prpContent_upload","JPG,PDF,DOC,DOCX,WPS",null,"");	
 //fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
	$("#prpContent_upload").find(".file").hide();//隐藏文本框
});


$(document).ready(function() {
	$("#org").attr("disabled","true");
	initDepartForComplete("org");
	 initControl();
});

function count(){
	var test = $("#work_time00").val();
	$("#num").text(test);
}

/**
 * 申报日期默认为当前日期
 */
$(document).ready(function() {


	var nowDate = '${sercverSysDate1}';
    if($("#submit_date").val()==""){
	   $("#submit_date").val(nowDate);
    }

});

/**
 * 填写检查
 */
function check(type){
	setTotalAmt();
	/* validate($("#fragment-tab1"),"项目基本情况"); */
	validate($("#basicInfo1"),"项目基本情况");
	validate($("#basicInfo2"),"项目基本情况");
	validate($("#basicInfo3"),"项目基本情况");
	validate($("#basicInfo4"),"项目基本情况");
	
	
	var prpkr_request_total=$("#prpkr_request_total").val();
	if(prpkr_request_total==""){
		prpkr_request_total=0;
	}
	var prpkr_request_invent=$("#prpkr_request_invent").val();
	if(prpkr_request_invent==""){
		prpkr_request_invent=0;
	}
	var prpkr_request_new=$("#prpkr_request_new").val();
	if(prpkr_request_new==""){
		prpkr_request_new=0;
	}
	if((parseInt(prpkr_request_invent)+parseInt(prpkr_request_new))>parseInt(prpkr_request_total)){
		irisValaddMsg("项目基本情况-->项目技术及知识产权状况-->项目已有知识产权状况-->专利申请总数必须大于等于发明申请总数加实用新型申请总数的和");
	}
	var prpkr_auth_total=$("#prpkr_auth_total").val();
	if(prpkr_auth_total==""){
		prpkr_auth_total=0;
	}
	var prpkr_auth_invent=$("#prpkr_auth_invent").val();
	if(prpkr_auth_invent==""){
		prpkr_auth_invent=0;
	}
	var prpkr_auth_new=$("#prpkr_auth_new").val();
	if(prpkr_auth_new==""){
		prpkr_auth_new=0;
	}
	if((parseInt(prpkr_auth_invent)+parseInt(prpkr_auth_new))>parseInt(prpkr_auth_total)){
		irisValaddMsg("项目基本情况-->项目技术及知识产权状况-->项目已有知识产权状况-->专利授权总数必须大于等于发明授权总数加实用新型授权总数的和");
	}

	
	validate($("#basicInfo5"),"项目基本情况");
	validate($("#basicInfo6"),"项目基本情况");
	
	validate($("#fragment-tab2"),"");
	
	validate($("#orgInfo"),"单位基本情况");
	
	validate($("#daitouren1"),"申请人情况-->1、基本信息 ");
	
	var university_name = $("#university_name").val();
	var university_time = $("#university_time").val();
	var university_system = $("#university_system").val();
	var university_mojor = $("#university_mojor").val();
	var degree1_value = $("#degree1_value").val();
	
  var master_name = $("#master_name").val();
	var master_time = $("#master_time").val();
	var master_system = $("#master_system").val();
	var master_mojor = $("#master_mojor").val();
	var degree2_value = $("#degree2_value").val();
	

	var doctor_name = $("#doctor_name").val();
	var doctor_time = $("#doctor_time").val();
	var doctor_system = $("#doctor_system").val();
	var doctor_mojor = $("#doctor_mojor").val();
	var degree3_value = $("#degree3_value").val();
	

	if(university_name!=""||university_time!=""||university_system!=""||university_mojor!=""||degree1_value!=""){
		 if(university_name==""||university_time==""||university_system==""||university_mojor==""||degree1_value==""){
			 irisValaddMsg("申请人情况-->学历 -->第一行（大学）请填写完整");
		 }
	    }
	if(master_name!=""||master_time!=""||master_system!=""||master_mojor!=""||degree2_value!=""){
		 if(master_name==""||master_time==""||master_system==""||master_mojor==""||degree2_value==""){
			 irisValaddMsg("申请人情况-->学历 -->第二行（硕士生）请填写完整");
		 }
	    }
	if(doctor_name!=""||doctor_time!=""||doctor_system!=""||doctor_mojor!=""||degree3_value!=""){
		 if(doctor_name==""||doctor_time==""||doctor_system==""||doctor_mojor==""||degree3_value==""){
			 irisValaddMsg("申请人情况-->学历 -->第三行（博士生）请填写完整");
		 }
	    }
	 
	 
	validate($("#xueli"),"申请人情况-->学历 ");
	validate($("#basicInfo7"),"申请人情况-->1、基本信息 ");
	validateByTabRow($("#basicInfo8"),"申请人情况-->2、外语水平",0);
	validate($("#gongzuo"),"申请人情况-->工作情况 ");
	validate($("#peiou"),"申请人情况-->配偶简况 ");
	
	
	
	
	validateByTabRow($("#tblMileStones1"),"简历与津贴人选-->简历-->（一）国内简历",1);
	validateByTabRow($("#tblMileStones2"),"简历与津贴人选-->简历-->（二）国外简历",0);
	validateByTabRow($("#tblMileStones11"),"简历与津贴人选-->津贴与人选-->（一）获政府特殊津贴情况",0);
	validateByTabRow($("#tblMileStones12"),"简历与津贴人选-->津贴与人选-->（二）获国家基金优青、省学科学术和技术带头人、青年科学家、赣鄱英才、井冈学者以上人才称号",0);
	validateByTabRow($("#tblMileStones13"),"简历与津贴人选-->津贴与人选-->（三）获百千万工程人选情况",0);
	
	validateByTabRow($("#tblMileStones4"),"近十年情况-->（一）近十年承担省部级及以上各类科技计划项目情况",0);
	validateByTabRow($("#tblMileStones5"),"近十年情况-->（二）近十年发表的主要著作、论文、重要技术报告及评价、被引用情况登记以及批准的发明专利",0);
	validateByTabRow($("#tblMileStones6"),"近十年情况-->（三）近十年获国内政府科技奖励情况",0);
	validateByTabRow($("#tblMileStones7"),"近十年情况-->（四）近十年获国外科技奖励情况",0);
	validateByTabRow($("#tblMileStones8"),"近十年情况-->（五）近十年获国内其他科技奖励情况",0);
	validateByTabRow($("#tblMileStones9"),"近十年情况-->（六）申报前五年已鉴定的科技成果产生的经济社会效益情况",0);
	validateByTabRow($("#tblMileStones10"),"近十年情况-->（七）申报前五年在企业技术创新（技术改造、技术发＜未鉴定成果＞等方面）产生的经济效益情况",0);
	
	
	
	
	

	

	var issuekr_request_total=$("#issuekr_request_total").val();
	if(issuekr_request_total==""){
		issuekr_request_total=0;
	}
	var issuekr_request_invent=$("#issuekr_request_invent").val();
	if(issuekr_request_invent==""){
		issuekr_request_invent=0;
	}
	var issuekr_request_new=$("#issuekr_request_new").val();
	if(issuekr_request_new==""){
		issuekr_request_new=0;
	}
	if((parseInt(issuekr_request_invent)+parseInt(issuekr_request_new))>parseInt(issuekr_request_total)){
		irisValaddMsg("单位基本情况-->单位拥有知识产权状况-->课题组中专利申请总数必须大于等于发明申请总数加实用新型申请总数的和");
	}
	var issuekr_auth_total=$("#issuekr_auth_total").val();
	if(issuekr_auth_total==""){
		issuekr_auth_total=0;
	}
	var issuekr_auth_invent=$("#issuekr_auth_invent").val();
	if(issuekr_auth_invent==""){
		issuekr_auth_invent=0;
	}
	var issuekr_auth_new=$("#issuekr_auth_new").val();
	if(issuekr_auth_new==""){
		issuekr_auth_new=0;
	}
	if((parseInt(issuekr_auth_invent)+parseInt(issuekr_auth_new))>parseInt(issuekr_auth_total)){
		irisValaddMsg("单位基本情况-->单位拥有知识产权状况-->课题组中的专利授权总数必须大于等于发明授权总数加实用新型授权总数的和");
	}

	var submitPsn = $("#submit_psn").parent("td").parent("tr");
	var zh_name = submitPsn.find("span[name$='zh_name']").text();
	var major = submitPsn.find("span[name$='major_work']").text();
	var birthday = submitPsn.find("span[name$='birthday']").text();
	var position = submitPsn.find("span[name$='position']").text();
	var degree_name = submitPsn.find("span[name$='degree_name']").text();
	var work = submitPsn.find("span[name$='work']").text();
	var org_name = submitPsn.find("span[name$='org_name']").text();
	var work_time = submitPsn.find("span[name$='work_time']").text();
	var prof_title_name = submitPsn.find("span[name$='prof_title_name']").text();
	if ( zh_name=="" || major=="" || birthday=="" || position=="" || degree_name=="" || work=="" || org_name=="" || prof_title_name=="") {
		irisValaddMsg("项目人员-->项目负责人信息(项目人员第一条)不完整");
	} 
	validateByTabRow($("#zh_persons"),"项目人员-->项目人员",2);
	validate($("#fragment-tab8"),"");

	var fund_all=$("#fund_all").val();
	if(fund_all==""){
		fund_all=0;
	}
	fund_all=parseFloat(fund_all);
	var province_fund=$("#province_fund").val();
	if(province_fund==""){
		province_fund=0;
	}
	province_fund=parseFloat(province_fund);
	$("#tblAttendOrg tbody tr:gt(0)").each(function(){
		fund_all=accAdd(fund_all,parseFloat($(this).find("span[name$='fund_all']").text()));
		province_fund=accAdd(province_fund,parseFloat($(this).find("span[name$='province_fund']").text()));
	});
	var total_invest_1_0=$("#total_invest_1_0").val();
	if(total_invest_1_0==""){
		total_invest_1_0=0;
	}
	total_invest_1_0=parseFloat(total_invest_1_0);
	if(fund_all!=total_invest_1_0){
		irisValaddMsg("项目经费-->来源合计必须等于项目进度及分工-->主承担单位分工情况-->总经费加项目进度及分工-->参与单位分工情况-->各行总经费的和");
	}
	var total_invest_2_0=$("#total_invest_2_0").val();
	if(total_invest_2_0==""){
		total_invest_2_0=0;
	}
	total_invest_2_0=parseFloat(total_invest_2_0);
	if(province_fund!=total_invest_2_0){
		irisValaddMsg("项目经费-->省财政拨款必须等于项目进度及分工-->主承担单位分工情况-->省财政经费加项目进度及分工-->参与单位分工情况-->各行省财政经费的和");
	}
	
	validateByTabRow($("#tblMileStones"),"项目进度及分工->项目进度",1);
	validate($("#coopOrgInfo"),"项目进度及分工");
	
	
		validate($("#performances"),"项目绩效-->项目绩效目标");
		
	
	//validate($("#instruction"),"项目绩效");
	/*irisJqValEmpty($("#fragment-tab8"),"项目绩效-->项目绩效目标表请完整填写");
	validate($("#fragment-tab8"),"项目绩效");
    <security:authorize ifNotGranted="A_DAILU_PROPOSAL">irisFundEmpty($("#finances"),"单位财务信息不完整，请联系单位管理员完善单位信息");</security:authorize><security:authorize ifAnyGranted="A_DAILU_PROPOSAL">irisFundEmpty($("#finances"),"请完善单位信息");</security:authorize>prp_attach();*/
    validate($("#fragment-tab11"),"可行性报告"); 
    prp_attach();
    validate($("#prp_intro1"),"项目简介表"); 
    validate($("#prp_intro2"),"项目简介表"); 
   /*  validate($("#fragment-tab10"),"项目简介表");  */
/*     var orgNum = $("#yanzheng_org").val(); 
   
    if(orgNum!=""&&orgNum!=null&&orgNum!="0"){ 
    	checkAttach(91011,0,'各参与单位联合申报项目的证明文件','');	
    	checkAttach(91005,0,'各参与单位联合申报项目的证明文件','');	
    } */
	if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	if(type=="check"){
		showBox($("#wbox1"), "300px", "200px", "检查通过","1:所有检查全部合格");
	}
	return true;
}

	/**
	 * 验证table里有空就完整填写 针对表格里都为必添 例:irisJqValEmpty("tabid","经费信息请完整填写");
	 */
	function irisJqValEmpty2(obj, msg) {
		
		var sum=0;
		obj.find(":input,textarea").not("input[name='performances/summary_hidden']").each(function() {
			if($(this).val()==''){
				sum+=1;
			}
		});
		if(sum!=0)
		irisValaddMsg(msg);
		
		return sum;
	}



function setTotalAmt(){
	/* $('#total_amt').val($("#input_total").val()); */
	$('#request_amt').val($("#total_invest_0").val());
}

</script>
<style>
	textarea{overflow:   auto;}
</style>
</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" />
	<x:parse xml="${xmlstr}" var="xmlData" scope="request"/>
	<input type="hidden" id="childDiv" class="thickbox"/>
	<input type="hidden" id="filePath" value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />
	
	<div id="showMessage"></div>
	<div id="content">
		<cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			  <!-- 公用的配置界面 ：保存、提交等button-->
		    <jsp:include page="./prpeditmain_public_first.jsp"></jsp:include>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" />
				<span class="right">版本号：<span name="proposal/prp_version" id="prp_version"><x:out select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> 
				<input type="hidden" value="${posCode}" id="posCode" name="posCode"> 
				<input type="hidden" value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes" name="posCodeDes">
				<input type="hidden" value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>" id="pdfCodeDes" name="pdfCodeDes">  
				<input type="hidden" value="${xmlData}" id="xmlData" name="xmlData">
				<input type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode"> 
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi" name="proposal/flag_shizhi"> 
			</form>
				<div class="word_title">
				<c:set var="statYear">${statYear}</c:set>
				<c:if test="${empty statYear}">
					<c:set var="statYear"><x:out select="$xmlData/data/proposal/stat_year" /></c:set>
				</c:if>
				<input type="hidden" name="proposal/stat_year" value="${statYear}">
				<span name="proposal/grant_name" ><x:out select="$xmlData/data/proposal/grant_name" /></span>-项目申请书 (<span name="proposal/stat_year">${statYear}</span>年)<br />
				(<x:out select="$xmlData/data/proposal/sub_grant_name"/>)
				 <!-- 公用的配置界面 -->
				    <jsp:include page="./prpeditmain_public.jsp"></jsp:include>
				</div>
				<div id="tabnav">
					<ul>
						<li class="down" id="tab1" onclick="changeTab(this.id);count();">
						    <a href="###"><span>项目基本情况</span></a>
						</li>
						
						<li  id="tab2" onclick="changeTab(this.id)">
						    <a href="###"><span>项目概况</span></a>
						</li>
						
						<li id="tab3" onclick="changeTab(this.id)" >
						    <a href="###"><span>单位基本情况</span></a>
						</li>
						
						<li id="tab4" onclick="changeTab(this.id)" >
						    <a href="###"><span>申请人情况</span></a>
						</li>
						
						<li id="tab5" onclick="changeTab(this.id)" >
						    <a href="###"><span>简历与津贴人选</span></a>
						</li>
						
						<li id="tab6" onclick="changeTab(this.id)" >
						    <a href="###"><span>近十年情况</span></a>
						</li>
						
						<li id="tab7" onclick="changeTab(this.id)" >
						    <a href="###"><span>项目人员</span></a>
						</li>
						
						<li id="tab8" onclick="changeTab(this.id)">
						    <a href="###"><span>项目经费</span></a>
						</li>	
					 </ul>
				</div>
				<div id="tabnav">
					<ul>
						<li id="tab9" onclick="changeTab(this.id)" >
						    <a href="###"><span>项目进度及分工</span></a>
						</li>

						<li id="tab10" onclick="changeTab(this.id)" >
						    <a href="###"><span>项目绩效</span></a>
						</li>
						
						<li id="tab11" onclick="changeTab(this.id)" >
						    <a href="###"><span>可行性报告</span></a>
						</li>	
						
						<li id="tab12" onclick="changeTab(this.id)" >
						    <a href="###"><span>附件清单</span></a>
						</li>
				
						<li id="tab13" onclick="changeTab(this.id)" >
						    <a href="###"><span>项目简介表</span></a>
						</li>
			        </ul>
			    </div>
				<div class="tab_box" id="fragment-tab1">
					<jsp:include page="../info/prpInfoEdit_kjcxrc.jsp">
					 <jsp:param value="${statYear }" name="statYear" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab2" style="display: none">
					<jsp:include page="../goal/prpgoaledit_xmgk_kjcxrc.jsp">
					   <jsp:param value="项目概况" name="title" />
					</jsp:include>
				</div>
				
				<div class="tab_box" id="fragment-tab3" style="display: none">
					<jsp:include page="../org/prporg_baseinfo_kjcxrc.jsp">
              <jsp:param value="基本信息" name="title"/>
          </jsp:include>
				</div>
				
				
				
				<div class="tab_box" id="fragment-tab4" style="display: none">
					<jsp:include page="../psn/prpzhpsn_kjcxrc1.jsp">
						<jsp:param value="申请人情况" name="title" />
					</jsp:include>
				</div>
				
				
				<div class="tab_box" id="fragment-tab5" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_kjcxrc2.jsp">
					<jsp:param value="简历与津贴人选" name="title" />
					</jsp:include>
				</div>
				
				
				<div class="tab_box" id="fragment-tab6" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_kjcxrc1.jsp">
					<jsp:param value="近十年情况" name="title" />
					</jsp:include>
				</div>
				

			
				<div class="tab_box" id="fragment-tab7" style="display: none">
					<jsp:include page="../psn/prpzhpsn_kjcxrc_2016.jsp">
						<jsp:param value="项目人员（限20人）" name="title" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab8" style="display: none">
					<jsp:include page="../fund/prpfundedit_kjcxrc_2016.jsp">
					    <jsp:param value="${statYear}" name="statYear" />
						<jsp:param value="项目经费" name="title" />
						<jsp:param value="（单位：万元，保留两位小数）" name="unit"/>
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab9" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_kjcxrc_2016.jsp"></jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab10" style="display: none">
					<jsp:include page="../performance/prpperformanceedit_kjcxrc.jsp">
					 <jsp:param value="项目绩效目标" name="title" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab11" style="display: none">
					<jsp:include page="../content/prpContentEdit_kjcxrc.jsp"></jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab12" style="display: none">
					<jsp:include page="../attach/prpAttachEdit_by_kjcxrc.jsp">
					    <jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab13" style="display: none">
					<jsp:include page="../info/prpInfoEdit_intro_kjcxrc.jsp">
					<jsp:param value="项目简介表" name="title" />
					</jsp:include>
				</div>
			<!-- 公用的配置界面 ：保存、提交等button -->
			<jsp:include page="./prpeditmain_public_last.jsp"></jsp:include>
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>